﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;

namespace CrawlerApp.Infrastructure.Interfaces
{
    public interface IRepository<T>
    {
        Task<T> GetByIdAsync(int id, bool onChange = false, CancellationToken cancellationToken = default);
        Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> predicate, bool onChange = false, CancellationToken cancellationToken = default);
        Task<T> SingleOrDefaultAsync(Expression<Func<T, bool>> predicate = null, bool onChange = false, CancellationToken cancellationToken = default);
        Task<IReadOnlyCollection<T>> ToListAsync(Expression<Func<T, bool>> whereExpression = null, bool onChange = false, CancellationToken cancellationToken = default);
        bool Exists(Expression<Func<T, bool>> predicate);
        Task<bool> ExistsAsync(Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default);
        Task<T> AddAsync(T entity, CancellationToken cancellationToken = default);
        Task<IReadOnlyCollection<T>> AddRangeAsync(IReadOnlyCollection<T> entities, CancellationToken cancellationToken = default);
        Task UpdateAsync(T entity, CancellationToken cancellationToken = default);
        Task DeleteAsync(T entity, CancellationToken cancellationToken = default);
    }
}
